import utime as time
import app_config
import uos



#把可读写的文件移动到可读写的用户文件夹区域，系统优先识别/haas/目录下的board.json、cfg.json
list_json = uos.listdir("/haas/")
# print(list_json)
if ("board.json" and "cfg.json") in list_json: 
    pass
else:
    uos.rename("/luadb/cfg.json","/haas/cfg.json")
    uos.rename("/luadb/board.json","/haas/board.json")


if __name__ == '__main__':
    #读取cfg信息------------------------------------------------------
    cfg_result = app_config.read_cfg_data() 
    print('cfg_result',cfg_result)
    print('''name:{},
    timestamp:{},
    hearttime:{},
    clientId:{},
    AccessToken:{},
    ProjectKey:{}'''.format(cfg_result["name"],cfg_result["timestamp"],cfg_result["hearttime"],cfg_result["triad"]["clientId"],cfg_result["triad"]["AccessToken"],cfg_result["triad"]["ProjectKey"]))
    #更改下面三元组写入---------------------------------
    clientId=""
    AccessToken=""
    ProjectKey=""
    #---------------------------------------------------
    app_config.write_cfg({"clientId":clientId})
    app_config.write_cfg({"AccessToken":AccessToken})
    app_config.write_cfg({"ProjectKey":ProjectKey})
    
    while True:
        time.sleep(1)



